package 反射第二遍.demo18;

import java.lang.reflect.Field;

/**
 * @author wql
 * @version 1.0
 * @date 2022/10/27 15:45
 */

public class Test {
    public static void main(String[] args) throws Exception{
        Class<haha> hahaClass = haha.class;
        Field address = hahaClass.getDeclaredField("address");
        System.out.println(address);
        Field[] declaredFields = hahaClass.getDeclaredFields();
        for (Field declaredField : declaredFields) {
            System.out.println(declaredField);
        }

        Field name = hahaClass.getField("name");
        System.out.println(name);

        Field[] fields = hahaClass.getFields();
        for (Field field : fields) {
            System.out.println("field = " + field);
        }
    }
}
class hehe{
    public String name;
    private  Integer age;
}
class haha extends hehe{
    public String address;
    private Integer num;

    @Override
    public String toString() {
        return "haha{" +
                "address='" + address + '\'' +
                ", num=" + num +
                '}';
    }
}
